
<?php
require "../dao/menudao.php";

class menu{
	
	private $_menu;//业务模型
	//private $action;
	
	
	
	public function __construct(){
		$dao=new menudao();
		$this->_menu=$dao->Chaxun();
		//var_dump($this->_menu);
		
	}
	

	//获取菜单
	public function getmenu(){
		//找出一级菜单
		foreach ($this->_menu as $item =>$values){
			if($values['pid']==0){
				
				//找出该一级菜单的子菜单
				$values['child']=$this->getchildmenu($values);
				$this->_menu[$item]=$values;
			}
		}
		return $this->_menu;
	}
	
	//获取子菜单
	public function getchildmenu($father){
		
		//找到下级菜单
		$childmenu=array();
		foreach ($this->_menu as $item =>$val){
			if($val['pid']==$father['mid']){
				$childmenu[]=$val;
				unset($this->_menu[$item]);
			}
		}
		return $childmenu;
	}
}		
		
$m=new menu();
$menus=$m->getmenu();
//var_dump($menus);
?>
<!--  -->
<link href=".././css.css" rel="stylesheet"/> 
<ul style="text-align:center;">
<?php foreach($menus as $item=>$menu) {?>
	<li class="1ji" style="width: 200px;
	line-height:50px;
	text-align: center;
	font-size: 20px;
	color: #0C5404; 
	margin-top:20px"><?php echo $menu['mname'] ?>
	<ul class="2ji" style="
	width: 200px;
	line-height: 20px;
	text-align: center;	
	display:none
	">
	<?php foreach($menu['child'] as $ite=>$men ){?>
	<li ><a style="font-size: 15px;color:#f2b558;" href="main.php?url=<?php echo $men['url']?>"><?php echo $men['mname'] ?></a></li>
	<?php }?></ul></li><?php  ?>


	
<?php 
 } ?> 
 </ul>






